package com.pokermind.model.dto;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.math.BigDecimal;
import java.util.List;

/**
 * 手牌完成请求DTO - V4.1优化版
 * 
 * V4.1变更：增加table_id和hand_id字段
 * 
 * @author PokerMind Team
 */
public class HandCompletionRequest {
    
    @JsonProperty("table_id")
    private String tableId;
    
    @JsonProperty("hand_id")
    private String handId;
    
    @JsonProperty("completion_type")
    private String completionType;
    
    @JsonProperty("players_to_showdown")
    private Integer playersToShowdown;
    
    @JsonProperty("final_pot")
    private BigDecimal finalPot;
    
    @JsonProperty("rake_amount")
    private BigDecimal rakeAmount;
    
    @JsonProperty("final_results")
    private List<FinalResult> finalResults;
    
    @JsonProperty("run_it_twice")
    private RunItTwiceConfig runItTwice;
    
    // 默认构造函数
    public HandCompletionRequest() {}
    
    // Getters and Setters
    public String getTableId() {
        return tableId;
    }
    
    public void setTableId(String tableId) {
        this.tableId = tableId;
    }
    
    public String getHandId() {
        return handId;
    }
    
    public void setHandId(String handId) {
        this.handId = handId;
    }
    
    public String getCompletionType() {
        return completionType;
    }
    
    public void setCompletionType(String completionType) {
        this.completionType = completionType;
    }
    
    public Integer getPlayersToShowdown() {
        return playersToShowdown;
    }
    
    public void setPlayersToShowdown(Integer playersToShowdown) {
        this.playersToShowdown = playersToShowdown;
    }
    
    public BigDecimal getFinalPot() {
        return finalPot;
    }
    
    public void setFinalPot(BigDecimal finalPot) {
        this.finalPot = finalPot;
    }
    
    public BigDecimal getRakeAmount() {
        return rakeAmount;
    }
    
    public void setRakeAmount(BigDecimal rakeAmount) {
        this.rakeAmount = rakeAmount;
    }
    
    public List<FinalResult> getFinalResults() {
        return finalResults;
    }
    
    public void setFinalResults(List<FinalResult> finalResults) {
        this.finalResults = finalResults;
    }
    
    public RunItTwiceConfig getRunItTwice() {
        return runItTwice;
    }
    
    public void setRunItTwice(RunItTwiceConfig runItTwice) {
        this.runItTwice = runItTwice;
    }
    
    /**
     * Run It Twice 配置类 (V4.5新增)
     */
    public static class RunItTwiceConfig {
        @JsonProperty("enabled")
        private Boolean enabled;
        
        @JsonProperty("runs")
        private List<RunResult> runs;
        
        public RunItTwiceConfig() {}
        
        public Boolean getEnabled() {
            return enabled;
        }
        
        public void setEnabled(Boolean enabled) {
            this.enabled = enabled;
        }
        
        public List<RunResult> getRuns() {
            return runs;
        }
        
        public void setRuns(List<RunResult> runs) {
            this.runs = runs;
        }
        
        /**
         * 单次运行结果
         */
        public static class RunResult {
            @JsonProperty("run")
            private Integer run;
            
            @JsonProperty("board")
            private List<String> board;
            
            @JsonProperty("pot_share")
            private BigDecimal potShare;
            
            @JsonProperty("winners")
            private List<String> winners;
            
            @JsonProperty("details")
            private List<PlayerRunDetail> details;
            
            public RunResult() {}
            
            public Integer getRun() {
                return run;
            }
            
            public void setRun(Integer run) {
                this.run = run;
            }
            
            public List<String> getBoard() {
                return board;
            }
            
            public void setBoard(List<String> board) {
                this.board = board;
            }
            
            public BigDecimal getPotShare() {
                return potShare;
            }
            
            public void setPotShare(BigDecimal potShare) {
                this.potShare = potShare;
            }
            
            public List<String> getWinners() {
                return winners;
            }
            
            public void setWinners(List<String> winners) {
                this.winners = winners;
            }
            
            public List<PlayerRunDetail> getDetails() {
                return details;
            }
            
            public void setDetails(List<PlayerRunDetail> details) {
                this.details = details;
            }
        }
        
        /**
         * 单个玩家在单次运行中的详情
         */
        public static class PlayerRunDetail {
            @JsonProperty("player_id")
            private String playerId;
            
            @JsonProperty("hand_rank")
            private String handRank;
            
            @JsonProperty("hand_desc")
            private String handDesc;
            
            @JsonProperty("result")
            private BigDecimal result;
            
            public PlayerRunDetail() {}
            
            public String getPlayerId() {
                return playerId;
            }
            
            public void setPlayerId(String playerId) {
                this.playerId = playerId;
            }
            
            public String getHandRank() {
                return handRank;
            }
            
            public void setHandRank(String handRank) {
                this.handRank = handRank;
            }
            
            public String getHandDesc() {
                return handDesc;
            }
            
            public void setHandDesc(String handDesc) {
                this.handDesc = handDesc;
            }
            
            public BigDecimal getResult() {
                return result;
            }
            
            public void setResult(BigDecimal result) {
                this.result = result;
            }
        }
    }
    
    /**
     * 最终结果内部类
     */
    public static class FinalResult {
        @JsonProperty("seat_number")
        private Integer seatNumber;
        
        @JsonProperty("player_id")
        private String playerId;
        
        @JsonProperty("player_name")
        private String playerName;
        
        @JsonProperty("final_stack")
        private BigDecimal finalStack;
        
        @JsonProperty("net_result")
        private BigDecimal netResult;
        
        @JsonProperty("cards")
        @JsonAlias("hole_cards")  // V4.7: 兼容客户端的hole_cards字段名
        private List<String> cards;  // ✅ V4.8新增：实际底牌
        
        @JsonProperty("cards_shown")
        private List<String> cardsShown;
        
        @JsonProperty("hand_rank")
        private String handRank;
        
        @JsonProperty("hand_description")
        private String handDescription;
        
        // 默认构造函数
        public FinalResult() {}
        
        // Getters and Setters
        public Integer getSeatNumber() {
            return seatNumber;
        }
        
        public void setSeatNumber(Integer seatNumber) {
            this.seatNumber = seatNumber;
        }
        
        public String getPlayerId() {
            return playerId;
        }
        
        public void setPlayerId(String playerId) {
            this.playerId = playerId;
        }
        
        public String getPlayerName() {
            return playerName;
        }
        
        public void setPlayerName(String playerName) {
            this.playerName = playerName;
        }
        
        public BigDecimal getFinalStack() {
            return finalStack;
        }
        
        public void setFinalStack(BigDecimal finalStack) {
            this.finalStack = finalStack;
        }
        
        public BigDecimal getNetResult() {
            return netResult;
        }
        
        public void setNetResult(BigDecimal netResult) {
            this.netResult = netResult;
        }
        
        public List<String> getCards() {
            return cards;
        }
        
        public void setCards(List<String> cards) {
            this.cards = cards;
        }
        
        public List<String> getCardsShown() {
            return cardsShown;
        }
        
        public void setCardsShown(List<String> cardsShown) {
            this.cardsShown = cardsShown;
        }
        
        public String getHandRank() {
            return handRank;
        }
        
        public void setHandRank(String handRank) {
            this.handRank = handRank;
        }
        
        public String getHandDescription() {
            return handDescription;
        }
        
        public void setHandDescription(String handDescription) {
            this.handDescription = handDescription;
        }
    }
}